<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <!-- 开发环境版本，包含了有帮助的命令行警告 -->
    <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
  </head>
  <body>
    <div id="app">
      <!-- View -->
      <div>
        <p>用户名：<input v-model="username" /></p>
        <p>密码：<input v-model="password"//></p>
        <button @click="login">登录</button>
      </div>
    </div>

    <script>
      // 组件的作用：复用
      // ViewModel
      new Vue({
        el: '#app',
        // model
        data: {
          username: '',
          password: ''
        },
        methods: {
          login() {
            console.log(this.username, this.password)
          }
        }
      })
    </script>
  </body>
</html>
